USERHOME := /home/weilaidb

#generate the path
CURRENT_PATH:=$(shell pwd)
#the current kernel version number
LINUX_KERNEL:=$(shell uname -r)
#the absolute path
#LINUX_KERNEL_PATH:=/usr/src/linux-headers-$(LINUX_KERNEL)
LINUX_KERNEL_PATH := $(USERHOME)/kernel/linux.old1
MODULE_PATH := $(USERHOME)/kernel/selfqemu/modules
BUSYBOX_PATH := $(USERHOME)/kernel/selfqemu/rootfs/busybox-1.36.1
BUSYBOX_INSTALL_PATH := $(USERHOME)/kernel/selfqemu/rootfs/busybox-1.36.1/_install


LOCALFILE:=my_char_driver

obj-m += $(LOCALFILE).o

all: compile copy

compile:
	cd $(CURRENT_PATH) && make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules

copy:
	mkdir -p $(BUSYBOX_INSTALL_PATH)
	cp -af $(CURRENT_PATH)/$(LOCALFILE).ko $(BUSYBOX_INSTALL_PATH)


clean:
	make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean



